package com.idc.test;

import com.alibaba.excel.metadata.data.FormulaData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.context.CellWriteHandlerContext;

public class FormulaHandler implements CellWriteHandler {
    @Override
    public void afterCellDispose(CellWriteHandlerContext context) {
		if (context.getColumnIndex() == 3) { // 指定公式列（如第4列）
            WriteCellData<?> cellData = context.getFirstCellData();
			FormulaData formulaData = new FormulaData();
			formulaData.setFormulaValue("C" + (context.getRowIndex() + 1) + "*1.1");
			cellData.setFormulaData(formulaData);
        }
    }
}
